package com.likou.second_challenge;

public class q160 {
    public class Solution {
        public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
            ListNode pA = headA;
            ListNode pB = headB;

            while (pA != pB) {
                pA = pA.next != null ? pA.next : headB;
                pB = pB.next != null ? pB.next : headA;
            }

            return pA;
        }
    }
}
